package com.example.test;

import java.io.File;
import java.lang.reflect.Modifier;

import com.example.interceptor.NameInterceptor;
import com.example.tcls.Moo;

import net.bytebuddy.ByteBuddy;
import net.bytebuddy.implementation.FieldAccessor;

/**
 * 
 * 然后通过FieldAccessor为我们新声明的name属性加入getter/setter方法：
 * @author simple
 *
 */
public class TMooFieldGetSet {

	public static void main(String[] args) throws Exception{

		new ByteBuddy()
        .subclass(Moo.class)
        .defineField("name", String.class, Modifier.PUBLIC)
        .implement(NameInterceptor.class).intercept(FieldAccessor.ofBeanProperty())
        .make().saveIn(new File("/Users/chenfeihao/Desktop/"));
	}

}
